package com.nidu.demo.common.enums;

import com.nidu.demo.common.validation.IntArrayValuable;
import cn.hutool.core.util.ArrayUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum StatusEnum implements IntArrayValuable {
    DISABLE(0, "禁用"),

    ENABLE(1, "启用");

    private final Integer value;

    private final String desc;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(StatusEnum::getValue).toArray();

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static StatusEnum of(Integer val) {
        return ArrayUtil.firstMatch(o -> o.getValue().equals(val), values());
    }
} 